package com.zw.yzk.kabu.mapper;

import com.zw.yzk.kabu.data.network.entity.ExhibitionTicketEntity;
import com.zw.yzk.kabu.model.MyTicketModel;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Inject;

/**
 * Created by zhanwei on 2017/3/9.
 */

public class MyTicketMapper {

    @Inject
    public MyTicketMapper() {
    }

    public MyTicketModel transfer(ExhibitionTicketEntity.Ticket ticket) {
        MyTicketModel model = new MyTicketModel();
        model.setImage(ticket.coverImage);
        model.setTitle(ticket.exhibitionName);
        model.setTime(ticket.date);
        model.setId(ticket.id);
        model.setPrice(ticket.price);
        model.setTotalPrice(ticket.totalPrice);
        model.setCount(ticket.count);
        model.setCheckTicketTime(ticket.checkTicketTime);
        model.setTicketType(ticket.ticketType);
        model.setPhone(ticket.phone);
        model.setSerialNumber(ticket.serialNumber);
        model.setUserId(ticket.userId);
        model.setEndTime(ticket.endTime);
        model.setStartTime(ticket.startTime);
        model.setAddress(ticket.address);
        model.setOrderState(ticket.orderState);
        model.setCheckCode(ticket.checkCode);
        model.setQrCodeUrl(ticket.qrCodeUrl);
        model.setInvalid(ticket.isExpired == 1);

        return model;
    }

    public List<MyTicketModel> transfer(List<ExhibitionTicketEntity.Ticket> ticketList) {
        List<MyTicketModel> modelList = new ArrayList<>();
        if (ticketList == null || ticketList.isEmpty()) {
            return modelList;
        }
        for (ExhibitionTicketEntity.Ticket ticket : ticketList) {
            modelList.add(transfer(ticket));
        }
        return modelList;
    }
}
